<template>
  <!-- 业务组件配置管理 -->
  <div class="business-main">
    <!-- 状态选择框 -->
    <div class="topbar-view">
      <topBarButVue :isshowedit="true" :isshowsave="true" @getstau="getstau" />
    </div>
    <!-- 业务组件展示表格 -->
    <div class="zh-table-view">
      <el-table :data="tableData" style="width: 100%" height="100%">
        <el-table-column type="index" width="50" />
        <el-table-column prop="assemblyName" label="中文名称" width="180" />
        <el-table-column prop="assemblyEnName" label="英文描述" />
        <el-table-column prop="assemblyCode" label="组件编码" />
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="mini" type="success" @click="showlineallmes(scope.$index, scope.row)">查看详情</el-button>
            <el-button size="mini" type="warning" @click="dellineallmes(scope.$index, scope.row)">删除</el-button>
            <el-button size="mini" type="primary" @click="editlineallmes(scope.$index, scope.row)">修改</el-button>
          </template>
        </el-table-column>
      </el-table>
      <Pagination :page-size="pageSize" :current-page="currentPage" :total-size="totalSize"
        @changePageSize="changePageSize" @changeCurrentPage="changeCurrentPage" />
    </div>
    <!-- 新增业务组件的弹框 -->
    <div v-if="diastau === 1" class="add-components-dia">
      <div class="top-bar"></div>
      <div class="top-title-line">
        <div class="line-title">业务组件配置</div>
        <div class="line-close" @click="setdiaview(0)">
          <i class="el-icon-close"></i>
        </div>
      </div>
      <div class="screen-dia-main">
        <!-- 标题配置 -->
        <div class="title-config">
          <div class="dia-main-inputline">
            <div class="inputline-name">中文名称</div>
            <input v-model="addtitlrmes.assemblyName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">英文描述</div>
            <input v-model="addtitlrmes.assemblyEnName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件编码</div>
            <input v-model="addtitlrmes.assemblyCode" class="inputline-value" />
          </div>
          <!-- 后续新增字段 -->
          <div class="dia-main-inputline">
            <div class="inputline-name">组件颜色</div>
            <input v-model="addtitlrmes.color" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件边框</div>
            <input v-model="addtitlrmes.frame" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">弹窗名称</div>
            <input v-model="addtitlrmes.frameName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">弹窗布局</div>
            <input v-model="addtitlrmes.popup" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">标题名称</div>
            <input v-model="addtitlrmes.titleName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">标题布局</div>
            <input v-model="addtitlrmes.titleLayer" class="inputline-value" />
          </div>

          <div class="dia-main-inputline">
            <div class="inputline-name">组件图片</div>
            <div v-if="!addtitlrmes.assemblypictureId" class="icon-line-value">
              <div class="not-iconurl" @click="openselcetInputimg()">
                <i class="el-icon-plus not-iconsty"></i>
              </div>
            </div>
            <div v-else class="icon-line-value">
              <img class="icon-line-value" :src="addtitlrmes.assemblypicture" />
            </div>
          </div>

          <!-- <img
            src="blob:http://localhost:1016/ba540026-1f44-4388-ab77-4577a052583a"
            alt=""
          /> -->
          <!-- 后续新增字段END -->
          <div class="dia-main-inputline">
            <div class="inputline-name">上传图标</div>
            <div v-if="addtitlrmes.icon === ''" class="icon-line-value">
              <div class="not-iconurl" @click="openselcetInput()">
                <i class="el-icon-plus not-iconsty"></i>
              </div>
            </div>
            <div v-else class="icon-line-value">
              <img class="icon-line-value" :src="addtitlrmes.iconurl" />
            </div>
          </div>
        </div>
        <!-- 底部添加组件配置 -->
        <div v-for="(item, index) in addboxcomsList" :key="index" class="dia-main-addline">
          <div class="dia-main-inputline">
            <div class="inputline-name">组件id</div>
            <input v-model="item.showType" class="inputline-value" />
          </div>
          <!-- 可以选择的业务组件 -->
          <div class="components-line">
            <div class="slect-name">组件选择</div>
            <select v-model="item.showType" class="selcect-one">
              <option v-for="(comitem, comindex) in compnentsList" :key="comindex" :value="comitem.typ">
                {{ comitem.typ + "---" + comitem.des }}
              </option>
            </select>
          </div>
          <div class="components-line">
            <div class="slect-name">数据来源</div>
            <select v-model="item.dataSources" class="selcect-one">
              <option v-for="(sourceitem, sourceindex) in dataSourcesList" :key="sourceindex" :value="sourceitem.id">
                {{ sourceitem.name }}
              </option>
            </select>
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">数据编码</div>
            <input v-model="item.url" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件名称</div>
            <input v-model="item.unitName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件编码</div>
            <input v-model="item.cockpitAssemblyCode" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件颜色</div>
            <input v-model="item.colorMatching" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">宽度百分比</div>
            <input v-model="item.width" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">高度百分比</div>
            <input v-model="item.height" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">横轴位置</div>
            <input v-model="item.xAxis" type="number" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">竖轴位置</div>
            <input v-model="item.yAxis" type="number" class="inputline-value" />
          </div>
          <div class="addline-but">
            <div class="addline-but1" @click="delcomponentsmet(index)">
              删除此基础组件
            </div>
          </div>
        </div>
      </div>
      <div class="bottom-bar">
        <div class="bottom-bar-cancel" @click="addcomponentsmet()">
          增加组件
        </div>
        <div class="bottom-bar-confirm" @click="savemes()">确认保存</div>
      </div>
    </div>
    <!-- 查看详细信息 -->
    <div v-if="diastau === 2" class="add-components-dia">
      <div class="top-bar"></div>
      <div class="top-title-line">
        <div class="line-title">业务组件详细信息</div>
        <div class="line-close" @click="setdiaview(0)">
          <i class="el-icon-close"></i>
        </div>
      </div>
      <div class="screen-dia-main">
        <!-- 标题配置 -->
        <div class="title-config">
          <div class="dia-main-inputline">
            <div class="inputline-name">中文名称</div>
            <input v-model="contentmesage.assemblyName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">英文描述</div>
            <input v-model="contentmesage.assemblyEnName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件编码</div>
            <input v-model="contentmesage.assemblyCode" class="inputline-value" />
          </div>
          <!-- 后续新增字段 -->
          <div class="dia-main-inputline">
            <div class="inputline-name">组件颜色</div>
            <input v-model="contentmesage.color" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件边框</div>
            <input v-model="contentmesage.frame" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">弹窗名称</div>
            <input v-model="contentmesage.frameName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">弹窗布局</div>
            <input v-model="contentmesage.popup" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">标题名称</div>
            <input v-model="contentmesage.titleName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">标题布局</div>
            <input v-model="contentmesage.titleLayer" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件图片</div>
            <div v-if="contentmesage.assemblyImage === ''" class="icon-line-value">
              <div class="not-iconurl">
                <i class="el-icon-plus not-iconsty"></i>
              </div>
            </div>
            <div v-else class="icon-line-value">
              <img class="icon-line-value" :src="'data:image/jpeg;base64,' + contentmesage.assemblyImage" />
            </div>
          </div>
          <!-- 后续新增字段END -->
          <div class="dia-main-inputline">
            <div class="inputline-name">上传图标</div>
            <div v-if="contentmesage.iconurl === ''" class="icon-line-value">
              <div class="not-iconurl">
                <i class="el-icon-plus not-iconsty"></i>
              </div>
            </div>
            <div v-else class="icon-line-value">
              <img class="icon-line-value" :src="'data:image/jpeg;base64,' + contentmesage.iconurl"
                @click="openselcetInput()" />
            </div>
          </div>
        </div>
        <!-- 底部添加组件配置 -->
        <div v-for="(item, index) in contentmesage.assemblyContentDTOList" :key="index" class="dia-main-addline">
          <div class="dia-main-inputline">
            <div class="inputline-name">组件id</div>
            <input v-model="item.showType" class="inputline-value" />
          </div>
          <!-- 可以选择的业务组件 -->
          <div class="components-line">
            <div class="slect-name">组件选择</div>
            <select v-model="item.showType" class="selcect-one">
              <option v-for="(comitem, comindex) in compnentsList" :key="comindex" :value="comitem.typ">
                {{ comitem.typ + "---" + comitem.des }}
              </option>
            </select>
          </div>
          <div class="components-line">
            <div class="slect-name">数据来源</div>
            <select v-model="item.dataSources" class="selcect-one">
              <option v-for="(sourceitem, sourceindex) in dataSourcesList" :key="sourceindex" :value="sourceitem.id">
                {{ sourceitem.name }}
              </option>
            </select>
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">数据编码</div>
            <input v-model="item.url" class="inputline-value" />
          </div>

          <div class="dia-main-inputline">
            <div class="inputline-name">组件名称</div>
            <input v-model="item.unitName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件编码</div>
            <input v-model="item.cockpitAssemblyCode" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件颜色</div>
            <input v-model="item.colorMatching" class="inputline-value" />
          </div>

          <div class="dia-main-inputline">
            <div class="inputline-name">宽度百分比</div>
            <input v-model="item.width" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">高度百分比</div>
            <input v-model="item.height" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">横轴位置</div>
            <input v-model="item.xAxis" type="number" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">竖轴位置</div>
            <input v-model="item.yAxis" type="number" class="inputline-value" />
          </div>
        </div>
      </div>
    </div>
    <!-- 修改业务组件的弹框 -->
    <div v-if="diastau === 3" class="add-components-dia">
      <div class="top-bar"></div>
      <div class="top-title-line">
        <div class="line-title">业务组件修改</div>
        <div class="line-close" @click="setdiaview(0)">
          <i class="el-icon-close"></i>
        </div>
      </div>
      <div class="screen-dia-main">
        <!-- 标题配置 -->
        <div class="title-config">
          <div class="dia-main-inputline">
            <div class="inputline-name">中文名称</div>
            <input v-model="editContentmesage.assemblyName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">英文描述</div>
            <input v-model="editContentmesage.assemblyEnName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件编码</div>
            <input v-model="editContentmesage.assemblyCode" class="inputline-value" />
          </div>

          <!-- 后续新增字段 -->
          <div class="dia-main-inputline">
            <div class="inputline-name">组件颜色</div>
            <input v-model="editContentmesage.color" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件边框</div>
            <input v-model="editContentmesage.frame" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">弹窗名称</div>
            <input v-model="editContentmesage.frameName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">弹窗布局</div>
            <input v-model="editContentmesage.popup" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">标题名称</div>
            <input v-model="editContentmesage.titleName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">标题布局</div>
            <input v-model="editContentmesage.titleLayer" class="inputline-value" />
          </div>

          <div class="dia-main-inputline">
            <div class="inputline-name">组件图片</div>
            <div v-if="!editContentmesage.assemblypictureId" class="icon-line-value">
              <div class="not-iconurl" @click="openselcetInputimg()">
                <i class="el-icon-plus not-iconsty"></i>
              </div>
            </div>
            <div v-else class="icon-line-value">
              <img class="icon-line-value" :src="'data:image/jpeg;base64,' + editContentmesage.assemblyImage
                " @click="openselcetInputimg()" />
            </div>
          </div>
          <!-- 后续新增字段END -->

          <div class="dia-main-inputline">
            <div class="inputline-name">上传图标</div>
            <div v-if="editContentmesage.icon === ''" class="icon-line-value">
              <div class="not-iconurl" @click="openselcetInput()">
                <i class="el-icon-plus not-iconsty"></i>
              </div>
            </div>
            <div v-else class="icon-line-value">
              <img class="icon-line-value" :src="'data:image/jpeg;base64,' + editContentmesage.iconurl"
                @click="openselcetInput()" />
            </div>
          </div>
        </div>
        <!-- 底部添加组件配置 -->
        <div v-for="(item, index) in editContentmesage.assemblyContentDTOList" :key="index" class="dia-main-addline">
          <div class="dia-main-inputline">
            <div class="inputline-name">组件id</div>
            <input v-model="item.showType" class="inputline-value" />
          </div>
          <!-- 可以选择的业务组件 -->
          <div class="components-line">
            <div class="slect-name">组件选择</div>
            <select v-model="item.showType" class="selcect-one">
              <option v-for="(comitem, comindex) in compnentsList" :key="comindex" :value="comitem.typ">
                {{ comitem.typ + "---" + comitem.des }}
              </option>
            </select>
          </div>
          <div class="components-line">
            <div class="slect-name">数据来源</div>
            <select v-model="item.dataSources" class="selcect-one">
              <option v-for="(sourceitem, sourceindex) in dataSourcesList" :key="sourceindex" :value="sourceitem.id">
                {{ sourceitem.name }}
              </option>
            </select>
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">数据编码</div>
            <input v-model="item.url" class="inputline-value" />
          </div>

          <div class="dia-main-inputline">
            <div class="inputline-name">组件名称</div>
            <input v-model="item.unitName" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件编码</div>
            <input v-model="item.cockpitAssemblyCode" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">组件颜色</div>
            <input v-model="item.colorMatching" class="inputline-value" />
          </div>

          <div class="dia-main-inputline">
            <div class="inputline-name">宽度百分比</div>
            <input v-model="item.width" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">高度百分比</div>
            <input v-model="item.height" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">横轴位置</div>
            <input v-model="item.xAxis" type="number" class="inputline-value" />
          </div>
          <div class="dia-main-inputline">
            <div class="inputline-name">竖轴位置</div>
            <input v-model="item.yAxis" type="number" class="inputline-value" />
          </div>
          <div class="addline-but">
            <div class="addline-but1" @click="delcomponentsmettwo(index)">
              删除此基础组件
            </div>
          </div>
        </div>
      </div>
      <div class="bottom-bar">
        <div class="bottom-bar-cancel" @click="addcomponentsmettwo()">
          增加组件
        </div>
        <div class="bottom-bar-confirm" @click="savemesedit()">
          确认保存修改
        </div>
      </div>
    </div>
    <!-- 选择文件挂件-用完关掉 -->
    <input v-if="isshowuploadpic" ref="zhfileInput" type="file" accept="image/*" style="display: none"
      @change="getFile" />
    <input v-if="isshowuploadpic1" ref="zhfileInput1" type="file" accept="image/*" style="display: none"
      @change="getFile1" />
  </div>
</template>
<script>
import axios from "axios";
import topBarButVue from "../components/top-bar-but.vue";
import Pagination from "@/components/Pagination";
import { getTitleList } from "@/components/getnameurl";
export default {
  components: { topBarButVue, Pagination },
  data() {
    return {
      isshowuploadpic: false,
      isshowuploadpic1: false,

      tableData: [],
      pageSize: 10,
      currentPage: 1,
      totalSize: 0,
      contentmesage: {
        assemblyId: "",
        assemblyCode: "",
        //
        color: "green",
        frame: "",
        frameName: "",
        popup: 0,
        titleLayer: "",
        titleName: "",
        assemblypictureId: "",
        assemblyImage: "",
        //
        iconurl: "",
        assemblyContentDTOList: [
          // {
          //   "dataSources": 1,
          //   "showType": "A1",
          //   "xAxis": 1,
          //   "yAxis": 1
          // }
        ],
        assemblyEnName: "",
        assemblyName: ""
      },
      editContentmesage: {
        assemblyId: "",
        assemblyCode: "",
        //
        color: "green",
        frame: "",
        frameName: "",
        popup: 0,
        titleLayer: "",
        titleName: "",
        assemblypictureId: "",
        assemblypicture: "",
        assemblyImage: "",
        //
        assemblyContentDTOList: [
          // {
          //   "dataSources": 1,
          //   "showType": "A1",
          //   "xAxis": 1,
          //   "yAxis": 1
          // }
        ],
        assemblyEnName: "",
        assemblyName: ""
      },
      // ---添加相关---
      diastau: 0,
      addtitlrmes: {
        assemblyName: "基地简介",
        assemblyEnName: "Base Des",
        assemblyCode: "K1",
        //
        color: "green",
        frame: "",
        frameName: "",
        popup: 0,
        titleLayer: "",
        titleName: "",
        assemblypictureId: "",
        assemblypicture: "",
        //
        icon: "",
        iconurl: ""
      },
      // 要添加的信息
      addboxcomsList: [],
      // 数据来源
      dataSourcesList: [
        { name: "固定数据", id: 1 },
        { name: "动态数据", id: 0 }
      ],
      // 可选择的基础组件
      compnentsList: [],
      selectStau: ""
      // 先来个最基础的布局-这是要传给后端的结构
      // nowkuangmes: {
      //   titleMes: {
      //     name: "基地简介",
      //     titleImg: "bar1-1-1.png",
      //     titleDes: "JJ Lin"
      //   },
      //   assemblyHeight: 36,
      //   assemblyCode: 'K1',
      //   cockpitAssemblyContentList: [
      //     [
      //       {
      //         cockpitAssemblyCode: "CGY8iNzhP0",
      //         comType: "A1",
      //         dataSources: 1,
      //         url: "url1",
      //         width: 100
      //       }
      //     ]
      //   ]
      // }
    };
  },
  mounted() {
    this.getcomponentsMesList();
    this.gettabledataList();
  },
  methods: {
    // 上传图片
    openselcetInput() {
      this.isshowuploadpic = true;
      setTimeout(() => {
        this.$refs.zhfileInput.click();
      }, 100);
    },
    // 组件图
    openselcetInputimg() {
      this.isshowuploadpic1 = true;
      setTimeout(() => {
        this.$refs.zhfileInput1.click();
      }, 100);
    },
    // 图片选择返回数据
    getFile(event) {
      const files = event.target.files;
      let filename = files[files.length - 1].name; // 只有一个文件
      // this.name = filename
      // this.$emit('imagename', filename)
      if (filename.lastIndexOf(".") <= 0) {
        return alert("请添加一张图片!"); // 判断图片是否有效
      }
      const fileReader = new FileReader(); // 内置方法new FileReader()   读取文件
      // fileReader.readAsDataURL(files[files.length - 1]);
      fileReader.readAsBinaryString(files[files.length - 1]);
      fileReader.addEventListener("load", () => {
        // this.imageUrl = window.btoa(fileReader.result.toString());
        // let imageUrl = fileReader.result;
        if (this.diastau === 1) {
          this.addtitlrmes.icon = files[files.length - 1];
          this.addtitlrmes.iconurl = this.createObjectURL(
            files[files.length - 1]
          );
        }
        if (this.diastau === 3) {
          this.editContentmesage.icon = files[files.length - 1];
          this.editContentmesage.iconurl = this.createObjectURL(
            files[files.length - 1]
          );
        }
        this.isshowuploadpic = false;
      });
      var formData = new FormData();
      formData.append("file", event.target.files[0]);
      let baseurl = this.$zhurl;
      let requrl = baseurl + "/picture/add";
      axios({
        method: "POST",
        url: requrl,
        data: formData,
        headers: {
          "Content-Type": "application/json;charset=UTF-8"
        }
      }).then((res) => {
        if (this.diastau === 1) {
          this.addtitlrmes.icon = res.data.data;
        }
        if (this.diastau === 3) {
          this.editContentmesage.icon = res.data.data;
        }
      });
    },
    getFile1(event) {
      const files = event.target.files;
      let filename = files[files.length - 1].name; // 只有一个文件
      if (filename.lastIndexOf(".") <= 0) {
        return alert("请添加一张图片!"); // 判断图片是否有效
      }
      const fileReader = new FileReader(); // 内置方法new FileReader()   读取文件

      fileReader.readAsBinaryString(files[files.length - 1]);
      fileReader.addEventListener("load", () => {
        if (this.diastau === 1) {
          this.addtitlrmes.assemblypictureId = files[files.length - 1];
          this.addtitlrmes.assemblypicture = this.createObjectURL(
            files[files.length - 1]
          );
        }
        if (this.diastau === 3) {
          this.editContentmesage.assemblypictureId = files[files.length - 1];
          this.editContentmesage.assemblypicture = this.createObjectURL(
            files[files.length - 1]
          );
        }
        this.isshowuploadpic1 = false;
      });

      var formData = new FormData();
      formData.append("file", event.target.files[0]);
      let baseurl = this.$zhurl;
      let requrl = baseurl + "/picture/add";
      axios({
        method: "POST",
        url: requrl,
        data: formData,
        headers: {
          "Content-Type": "application/json;charset=UTF-8"
        }
      }).then((res) => {
        if (this.diastau === 1) {
          this.addtitlrmes.assemblypictureId = res.data.data;
        }
        if (this.diastau === 3) {
          this.editContentmesage.assemblypictureId = res.data.data;
        }
      });
    },

    // 获取文件url
    createObjectURL(blob) {
      if (window.URL) {
        return window.URL.createObjectURL(blob);
      } else if (window.webkitURL) {
        return window.webkitURL.createObjectURL(blob);
      } else {
        return null;
      }
    },
    // 获取表格信息
    gettabledataList() {
      let baseurl = this.$zhurl;
      let requrl = baseurl + "/assembly/queryPageList";
      axios({
        method: "GET",
        url: requrl,
        headers: {
          "Content-Type": "application/json;charset=UTF-8"
        },
        params: {
          page: this.currentPage,
          size: this.pageSize
        }
      }).then((response) => {
        let mes = response.data;
        if (mes.code === 1) {
          this.tableData = mes.data.list || [];
          this.totalSize = mes.data.total;
        } else {
          this.$message.warning("获取表格失败");
        }
      });
    },
    changePageSize(pageSize) {
      this.pageSize = pageSize;
      this.gettabledataList();
    },
    changeCurrentPage(currentPage) {
      this.currentPage = currentPage;
      this.gettabledataList();
    },
    // 查看详情
    showlineallmes(i, e) {
      let baseurl = this.$zhurl;
      let requrl = baseurl + "/assembly/query";
      axios({
        method: "GET",
        url: requrl,
        headers: {
          "Content-Type": "application/json;charset=UTF-8"
        },
        params: {
          assemblyId: e.assemblyId
        }
      }).then((res) => {
        if (res.data.data) {
          this.contentmesage = res.data.data;
          this.contentmesage.assemblyId = e.assemblyId;
          if (res.data.data.logo) {
            this.contentmesage.iconurl =
              "data:image/png;base64," + res.data.data.logo;
          } else {
            this.contentmesage.iconurl = "";
          }
          this.diastau = 2;
        }
      });
      // console.log(this.contentmesage);
    },
    // 删除一个业务组件
    dellineallmes(i, e) {
      this.$confirm('此操作将删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let baseurl = this.$zhurl;
        let requrl = baseurl + "/assembly/del";
        axios({
          method: "POST",
          url: requrl,
          headers: {
            "Content-Type": "application/json;charset=UTF-8"
          },
          data: {
            assemblyId: e.assemblyId
          }
        }).then((res) => {
          if (res.data.code === 1) {
            this.$message.success("删除成功！");
            this.gettabledataList();
          }
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      })

    },
    // 修改一个业务组件
    editlineallmes(i, e) {
      let baseurl = this.$zhurl;
      let requrl = baseurl + "/assembly/query";
      this.editContentmesage.assemblyId = e.assemblyId;
      axios({
        method: "GET",
        url: requrl,
        headers: {
          "Content-Type": "application/json;charset=UTF-8"
        },

        params: {
          assemblyId: e.assemblyId
        }
      }).then((res) => {
        if (res.data.data) {
          this.editContentmesage = res.data.data;
          if (res.data.data.logo) {
            this.editContentmesage.iconurl =
              "data:image/png;base64," + res.data.data.logo;
          } else {
            this.editContentmesage.iconurl = "";
          }
          this.diastau = 3;
          // this.gettabledataList()
        }
      });
    },
    // 保存要添加的业务的组件信息
    savemes() {
      let param = {
        assemblyName: this.addtitlrmes.assemblyName,
        assemblyEnName: this.addtitlrmes.assemblyEnName,
        assemblyCode: this.addtitlrmes.assemblyCode,
        //
        color: this.addtitlrmes.color,
        frame: this.addtitlrmes.frame,
        frameName: this.addtitlrmes.frameName,
        popup: this.addtitlrmes.popup,
        titleLayer: this.addtitlrmes.titleLayer,
        titleName: this.addtitlrmes.titleName,
        // 图片信息
        assemblypictureId: this.addtitlrmes.assemblypictureId,
        //
        icon: this.addtitlrmes.icon,
        assemblyContentDTOList: this.addboxcomsList
      };

      let baseurl = this.$zhurl;
      let requrl = baseurl + "/assembly/add";
      // if (this.addtitlrmes.iconurl && this.addtitlrmes.iconurl !== "") {
      //   formData.append("file", param.icon);
      // }
      axios({
        method: "POST",
        url: requrl,
        data: param,
        timeout: 10000,
        headers: {
          "Content-Type": "application/json;charset=UTF-8"
        }
      }).then((response) => {
        let mes = response.data;
        if (mes.code === 1) {
          this.diastau = 0;
          this.$message.success("添加成功！");
          this.gettabledataList();
        }
      });
    },
    // 修改时-保存要添加的业务的组件信息
    savemesedit() {
      let baseurl = this.$zhurl;
      let requrl = baseurl + "/assembly/edit";
      let param = {
        assemblyName: this.editContentmesage.assemblyName,
        assemblyEnName: this.editContentmesage.assemblyEnName,
        assemblyCode: this.editContentmesage.assemblyCode,
        // 还差一个图片信息
        assemblypictureId: this.editContentmesage.assemblypictureId,
        assemblyId: this.editContentmesage.assemblyId,
        //
        color: this.editContentmesage.color,
        frame: this.editContentmesage.frame,
        frameName: this.editContentmesage.frameName,
        popup: this.editContentmesage.popup,
        titleLayer: this.editContentmesage.titleLayer,
        titleName: this.editContentmesage.titleName,
        //
        icon: this.editContentmesage.icon,
        assemblyContentDTOList: this.editContentmesage.assemblyContentDTOList
      };
      // if (this.addtitlrmes.icon && this.addtitlrmes.icon !== "") {
      //   formData.append("file", param.icon);
      // }

      axios({
        method: "POST",
        url: requrl,
        data: param,
        timeout: 10000,
        headers: {
          "Content-Type": "application/json;charset=UTF-8"
        }
      }).then((response) => {
        let mes = response.data;
        if (mes.code === 1) {
          this.diastau = 0;
          this.$message.success("修改成功！");
          this.gettabledataList();
        }
      });
    },
    // 添加一个业务组件
    addcomponentsmet() {
      this.addboxcomsList.push({
        showType: "A1",
        dataSources: 1,
        url: "testcode1",
        width: 100,
        height: 100,
        xAxis: 1,
        yAxis: 1
      });
    },
    // 修改时-添加一个业务组件
    addcomponentsmettwo() {
      this.editContentmesage.assemblyContentDTOList.push({
        showType: "A1",
        dataSources: 1,
        url: "testcode1",
        width: 100,
        height: 100,
        xAxis: 1,
        yAxis: 1
      });
    },
    // 删除一个业务组件
    delcomponentsmet(i) {
      this.addboxcomsList.splice(i, 1);
    },
    // 修改时-删除一个业务组件
    delcomponentsmettwo(i) {
      this.editContentmesage.assemblyContentDTOList.splice(i, 1);
      this.$message.success("删除成功，请点击保存");
    },
    // 获取一个所有组件基础信息
    getcomponentsMesList() {
      this.compnentsList = getTitleList();
    },
    // 获取状态
    getstau(e) {
      this.selectStau = e;
      if (e === "add") {
        this.addtitlrmes = {
          assemblyName: "基地简介",
          assemblyEnName: "Base Des",
          assemblyCode: "K1",
          //
          color: "green",
          frame: "",
          frameName: "",
          popup: 0,
          titleLayer: "",
          titleName: "",
          //
          icon: "",
          iconurl: ""
        };
        this.diastau = 1;
      } else if (e === 'complete') {
        this.diastau = 0
      } else if (e === 'edit') {
        // this.diastau = 3
      }
    },
    // 设置弹框展示
    setdiaview(i) {
      this.diastau = i;
    }
  }
};
</script>

<style lang="scss" scoped>
.business-main {
  width: 100%;
  height: 100%;

  .topbar-view {
    width: 100%;
    margin-bottom: 5px;
  }

  .zh-table-view {
    width: 100%;
    height: calc(100% - 60px);
    position: relative;
  }
}

.add-components-dia {
  width: 482px;
  // height: 191px;
  background: #303640;
  border: 1px solid #005c6f;
  border-radius: 7px;
  position: fixed;
  top: 15%;
  left: 40%;
  // background-color: #005c6f;
  z-index: 99;

  .top-bar {
    width: 480px;
    height: 10px;
    background: linear-gradient(90deg, #3581fb 0%, #00faad 100%);
    border-radius: 7px 7px 0px 0px;
  }

  .top-title-line {
    width: 470px;
    height: 35px;
    line-height: 35px;
    padding: 6px 8px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #484a4e;

    .line-title {
      height: 20px;
      font-size: 14px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #ffffff;
      letter-spacing: 2px;
    }

    .line-close {
      color: #10d7c4;
      cursor: pointer;
    }

    .line-close:hover {
      color: #ffffff;
    }
  }

  .screen-dia-main {
    width: 482px;
    padding: 20px 10px;
    // max-height: 550px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 480px;

    .title-config {
      padding-bottom: 20px;
      border-bottom: #00faad 1px solid;
      margin-bottom: 10px;
    }

    .dia-main-inputline {
      width: 442px;
      margin-top: 5px;
      display: flex;
      // justify-content: center;
      align-items: center;

      .inputline-name {
        width: 90px;
        height: 24px;
        font-size: 16px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #ffffff;
        line-height: 24px;
        text-align: center;
      }

      .inputline-value {
        width: 350px;
        height: 32px;
        box-sizing: border-box;
        border-radius: 0px 0px 0px 0px;
        opacity: 1;
        border: 1px solid #494e57;
        box-sizing: border-box;
        outline: 0;
      }

      .icon-line-value {
        width: 48px;
        height: 48px;
        text-align: center;

        .not-iconurl {
          border: 1px dashed #d9d9d9;
          border-radius: 6px;
          cursor: pointer;
          position: relative;
          overflow: hidden;
        }

        .not-iconurl:hover {
          border-color: #1caf7e;
        }

        .not-iconsty {
          font-size: 20px;
          color: #8c939d;
          width: 48px;
          height: 48px;
          line-height: 48px;
          text-align: center;
        }
      }
    }

    .dia-main-addline {
      width: 442px;
      font-size: 16px;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #ffffff;
      line-height: 24px;
      border-bottom: #00faad 1px dashed;
      padding-bottom: 16px;
      margin-bottom: 10px;

      .components-line {
        display: flex;
        // justify-content: space-between;
        align-items: center;
        width: 442px;
        height: 48px;

        .slect-name {
          width: 90px;
          height: 36px;
          font-size: 16px;
          font-family: PingFang SC-Regular, PingFang SC;
          font-weight: 400;
          color: #ffffff;
          line-height: 36px;
          text-align: center;
        }

        .selcect-one {
          width: 350px;
          color: #00faad;
          margin-top: 12px;
          height: 36px;
          line-height: 36px;
          background-color: transparent;
          border: #00faad dashed 1px;
          cursor: pointer;

          option {
            background-color: #005c6f !important;
            color: #fff;
            cursor: pointer;
          }
        }
      }

      .addline-but {
        width: 442px;
        display: flex;
        justify-content: space-around;
        margin-top: 15px;

        .addline-but1 {
          color: #00faad;
          border: 1px solid #00faad;
          cursor: pointer;
          padding: 5px 10px;
        }

        .addline-but1:hover {
          color: #fff;
        }

        .addline-but2 {
          color: #3581fb;
          border: 1px solid #3581fb;
          cursor: pointer;
          padding: 5px 10px;
        }

        .addline-but2:hover {
          color: #fff;
        }
      }
    }

    .dia-main-addline:last-of-type {
      padding-bottom: 0;
      margin: 0;
      border: none;
    }

    .showkuang-one {
      position: relative;
      left: 41px;
      width: 400px;
      min-height: 200px;

      .kuangone-main {
        position: absolute;
        width: 100%;
        height: 400px;
      }
    }
  }

  .bottom-bar {
    width: 482px;
    height: 50px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 16px;

    .bottom-bar-cancel {
      width: 96px;
      height: 33px;
      border-radius: 5px 5px 5px 5px;
      border: 1px solid #0cb9ae;
      color: #0cb9ae;
      cursor: pointer;
      line-height: 33px;
      text-align: center;
    }

    .bottom-bar-cancel:hover {
      color: #00faad;
    }

    .bottom-bar-confirm {
      width: 96px;
      height: 33px;
      background: #0cb9ae;
      border-radius: 5px 5px 5px 5px;
      cursor: pointer;
      line-height: 33px;
      text-align: center;
    }

    .bottom-bar-confirm:hover {
      color: #10fab4;
    }
  }
}
</style>
